xists("notice_send")) { $haya_post_info_pagesize = $conf['postlist_pagesize']; $haya_post_info_page = ceil(($thread['posts'] + 1) / $haya_post_info_pagesize); $haya_post_info_page = max(1, $haya_post_info_page); $notice_thread_subject = $thread['subject']; $notice_thread_substr_subject = notice_substr($thread['subject'], 20); $notice_thread_url = url('thread-'.$thread['tid']); $notice_thread = '《'.$notice_thread_subject.'》'; $notice_post_message = $post['message']; $notice_post_substr_message = notice_substr($post['message'], 40, FALSE); $notice_post_url = url('thread-'.$thread['tid'].'-'.$haya_post_info_page).'#'.$post['pid']; $notice_user_url = url('user-'.$user['uid']); $notice_user_avatar_url = $user['avatar_url']; $notice_user_username = $user['username']; $notice_user = ' '.$notice_user_username.''; $notice_msg_tpl = '
在主题 《{thread_substr_subject}》 的回复中提到了你:
' .'
{post_substr_message}
'; $notice_msg = str_replace( array( '{thread_subject}', '{thread_substr_subject}', '{thread_url}', '{thread}', '{post_message}', '{post_substr_message}', '{post_url}', '{user_url}', '{user_avatar_url}', '{user_username}', '{user}' ), array( $notice_thread_subject, $notice_thread_substr_subject, $notice_thread_url, $notice_thread, $notice_post_message, $notice_post_substr_message, $notice_post_url, $notice_user_url, $notice_user_avatar_url, $notice_user_username, $notice_user ), $notice_msg_tpl ); } preg_match_all('/@([^\s|\/|:|@]+)/', $post['message_fmt'], $haya_post_info_usernames_fmt); preg_match_all('/@([^\s|\/|:|@]+)/', $post['message'], $haya_post_info_usernames); $haya_post_info_usernames_count = count($haya_post_info_usernames[1]); if ($haya_post_info_usernames_count > 0) { for ($i = 0; $i < $haya_post_info_usernames_count; $i++) { $haya_post_info_username = trim($haya_post_info_usernames[1][$i]); $haya_post_info_user = haya_post_info_user_read_by_username($haya_post_info_username); if (!$haya_post_info_user || empty($haya_post_info_user['uid'])) { continue; } $post['message_fmt'] = str_replace($haya_post_info_usernames_fmt[0][$i], '@' . $haya_post_info_user['username'] . '', $post['message_fmt']); $post['message'] = str_replace($haya_post_info_usernames[0][$i], '@' . $haya_post_info_user['username'] . '', $post['message']); if (function_exists("notice_send")) { notice_send($user['uid'], $haya_post_info_user['uid'], $notice_msg, 156); } } } post__update($pid, array( "message_fmt" => $post['message_fmt'], "message" => $post['message'], )); } $thread['subject'] = notice_substr($thread['subject'], 20); // 回复 $notice_message = '
'.lang('notice_lang_comment').''.lang('notice_message_replytoyou').'《'.$thread['subject'].'》
'.notice_substr($message, 40, FALSE).'
'; $recvuid = $thread['uid']; $recvuid != $quotepost['uid'] AND notice_send($uid, $recvuid, $notice_message, 2); //$quotepost['uid']可能是null,但不影响逻辑 // 引用 if(!empty($quotepid) && $quotepid > 0) { $notice_quote_message = '
'.lang('notice_lang_reply').''.lang('notice_message_replytoyou_at').'《'.$thread['subject'].'》'.lang('notice_message_replytoyou_for').'
'.notice_substr($quotepost['message'], 40, FALSE).'
'.notice_substr($message, 40, FALSE).'
'; notice_send($uid, $quotepost['uid'], $notice_quote_message, 2); } $return_html = param('return_html', 0); $update_array = array(); if((($add_credit==1)||($add_credit==0&& $credits<0))&&$credits!=0) $update_array['credits+']=$credits; if((($add_credit==1)||($add_credit==0&& $golds<0))&&$golds!=0) $update_array['golds+']=$golds; if((($add_credit==1)||($add_credit==0&& $rmbs<0))&&$rmbs!=0) $update_array['rmbs+']=$rmbs; $uid AND $update_array AND user_update($uid, $update_array); $uid AND $update_array AND $user['gid']>=100 AND user_update_group($uid); $message = ''; isset($update_array['credits+']) AND $message .= lang('credits1').$credits_op.$credits.' ' ; isset($update_array['golds+']) AND $message .= lang('credits2').$golds_op.$golds.' ' ; isset($update_array['rmbs+']) AND $message .= lang('credits3').$rmbs_op.$rmbs ; if($return_html) { $filelist = array();ob_start(); include _include(APP_PATH.'view/htm/post_list.inc.htm'); $s = ob_get_clean();message(0, $s); } else { $message = $message ? $message : lang('create_post_sucessfully'); message(0, $message); } // 直接返回帖子的 html // return the html string to browser. $return_html = param('return_html', 0); if($return_html) { $filelist = array(); ob_start(); include _include(APP_PATH.'view/htm/post_list.inc.htm'); $s = ob_get_clean(); message(0, $s); } else { message(0, lang('create_post_sucessfully')); } } } elseif($action == 'update') { $pid = param(2); $post = post_read($pid); empty($post) AND message(-1, lang('post_not_exists:')); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) AND message(-1, lang('thread_not_exists:')); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) AND message(-1, lang('forum_not_exists:')); $isfirst = $post['isfirst']; !forum_access_user($fid, $gid, 'allowpost') AND message(-1, lang('user_group_insufficient_privilege')); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); !$allowupdate AND !$post['allowupdate'] AND message(-1, lang('have_no_privilege_to_update')); !$allowupdate AND $thread['closed'] AND message(-1, lang('thread_has_already_closed')); if($method == 'GET') { $forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread'); $forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name')); // 如果为数据库减肥,则 message 可能会被设置为空。 // if lost weight for the database, set the message field empty. $post['message'] = htmlspecialchars($post['message'] ? $post['message'] : $post['message_fmt']); $attachlist = $imagelist = $filelist = array(); if($post['files']) { list($attachlist, $imagelist, $filelist) = attach_find_by_pid($pid); } // 编辑器支持 HTML 编辑 if($post['doctype'] == 1) { $post['message'] = htmlspecialchars($post['message_fmt']); } $content_num = $thread['content_buy']; $content_type = $thread['content_buy_type']=='0'?'1': $thread['content_buy_type']; if($group['allowsell']=="1") { $input['content_num_status'] = form_radio_yes_no('content_num_status', $content_num > 0 ? 1 : 0); } $post_update=1; $forum_structure_r = db_find_one('thread_structure',array('tid'=>$tid)); if($forumlist[$fid]['structure'] =='0') $forum_structure_count = 0; else $forum_structure_count = count(explode('|',$forumlist[$fid]['structure'])); // todo: $tagids = tag_thread_find_tagid_by_tid($tid, $forum['tagcatelist']); include _include(APP_PATH.'view/htm/post.htm'); } elseif($method == 'POST') { $subject = htmlspecialchars(param('subject', '', FALSE)); $message = param('message', '', FALSE); $doctype = param('doctype', 0); empty($message) AND message('message', lang('please_input_message')); mb_strlen($message, 'UTF-8') > 2048000 AND message('message', lang('message_too_long')); $arr = array(); if($isfirst) { $newfid = param('fid'); $forum = forum_read($newfid); empty($forum) AND message('fid', lang('forum_not_exists')); if($fid != $newfid) { !forum_access_user($fid, $gid, 'allowthread') AND message(-1, lang('user_group_insufficient_privilege')); $post['uid'] != $uid AND !forum_access_mod($fid, $gid, 'allowupdate') AND message(-1, lang('user_group_insufficient_privilege')); $arr['fid'] = $newfid; } if($subject != $thread['subject']) { mb_strlen($subject, 'UTF-8') > 80 AND message('subject', lang('subject_max_length', array('max'=>80))); $arr['subject'] = $subject; } $arr AND thread_update($tid, $arr) === FALSE AND message(-1, lang('update_thread_failed')); } $r = post_update($pid, array('doctype'=>$doctype, 'message'=>$message)); $r === FALSE AND message(-1, lang('update_post_failed')); $cjid = setting_get('cjid'); if($uid==$cjid){ $jp=param('jp'); $xnjp=param('xnjp'); $sj=param('sj'); $prizecount=param('prizecount'); $_r=db_find_one('thread',array('tid'=>$tid)); if($_r){db_update('thread',array('tid'=>$tid),array('jp'=>$jp,'sj'=>$sj,'xnjp'=>$xnjp,'prizecount'=>$prizecount));}} global $group; if($isfirst) { $new_fid = param('fid'); $check_result = check_or_not($group, $new_fid, 'thread'); if($check_result)check_set_thread_check($tid,'0'); } else { $check_result = check_or_not($group, $fid, 'thread'); if($check_result)check_set_post_check($pid,'0'); } if($group['allowsell']=="1") { $content_num_status = param('content_num_status'); $content_num = param('content_num');//下面添加 if($content_num < 0 ){//判断购买主题货币值小于零 $content_num = 1;//小于零强制写为一 } $content_type = credits_get_content_type_by_name(param('content_type')); if ($content_num_status && $content_num) db_update('thread', array('tid' => $tid), array('content_buy' => $content_num, 'content_buy_type' => $content_type)); else db_update('thread', array('tid' => $tid), array('content_buy' => 0)); } $forum_structure_r = $forumlist[$newfid]['structure']; $forum_structure= explode('|',$forum_structure_r); $forum_structure_count = count($forum_structure); $update_array = array(); for($i=0;$i<$forum_structure_count;$i++) $update_array['c'.($i+1)] = param('ini_'.($i+1),'-'); $_r = db_find_one('thread_structure',array('tid'=>$tid)); if($_r) db_update('thread_structure',array('tid'=>$tid),$update_array); else{ $update_array['tid']=$tid; db_insert('thread_structure',$update_array); } // todo: /* $tag_cate_id_arr = param('tag_cate_id', array(0)); $tagids_new = array_values($tag_cate_id_arr); $tagids_old = tag_thread_find_tagid_by_tid($tid); //print_r($tagids_new);print_r($tagids_old);exit; //新增的、删除的 $tag_id_delete = array_diff($tagids_old, $tagids_new); $tag_id_add = array_diff($tagids_new, $tagids_old); foreach($tag_id_delete as $tagid) { tag_thread_delete($tagid, $tid); } foreach($tag_id_add as $tagid) { tag_thread_create($tagid, $tid); } thread_update($tid, array('tagids'=>'', 'tagids_time'=>0)); */ if($isfirst) { $tagids = param('tagid', array(0)); $tagcatemap = $forum['tagcatemap']; foreach($forum['tagcatemap'] as $cate) { $defaulttagid = $cate['defaulttagid']; $isforce = $cate['isforce']; $catetags = array_keys($cate['tagmap']); $intersect = array_intersect($catetags, $tagids); // 比较数组交集 // 判断是否强制 if($isforce) { if(empty($intersect)) { message(-1, '请选择 ['.$cate['name'].']'); } } // 判断是否默认 if($defaulttagid) { if(empty($intersect)) { array_push($tagids, $defaulttagid); } } } $tagids = array_diff($tagids, array(0)); $tagids_new = $tagids; $tagids_old = tag_thread_find_tagid_by_tid($tid, $forum['tagcatelist']); $tag_id_delete = array_diff($tagids_old, $tagids_new); $tag_id_add = array_diff($tagids_new, $tagids_old); if($tag_id_delete) { foreach($tag_id_delete as $tagid) { $tagid AND tag_thread_delete($tagid, $tid); } } if($tag_id_add) { foreach($tag_id_add as $tagid) { $tagid AND tag_thread_create($tagid, $tid); } } thread_update($tid, array('tagids'=>'', 'tagids_time'=>0)); /* foreach($tagids as $tagid) { $tagid AND tag_thread_create($tagid, $tid); }*/ } message(0, lang('update_successfully')); //message(0, array('pid'=>$pid, 'subject'=>$subject, 'message'=>$message)); } } elseif($action == 'delete') { $pid = param(2, 0); if($method != 'POST') message(-1, lang('method_error')); $post = post_read($pid); empty($post) AND message(-1, lang('post_not_exists')); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) AND message(-1, lang('thread_not_exists')); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) AND message(-1, lang('forum_not_exists')); $isfirst = $post['isfirst']; !forum_access_user($fid, $gid, 'allowpost') AND message(-1, lang('user_group_insufficient_privilege')); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); !$allowdelete AND !$post['allowdelete'] AND message(-1, lang('insufficient_delete_privilege')); !$allowdelete AND $thread['closed'] AND message(-1, lang('thread_has_already_closed')); $set_check = setting_get('tt_check'); if($set_check['recycle']=='1'){ if($isfirst) { if($thread['OK']=='-2' && $group['see_check']) thread_delete($tid); else recycle_thread_delete($tid); } else { post_delete($pid); //post_list_cache_delete($tid); } } else { if($isfirst) { thread_delete($tid); } else { post_delete($pid); //post_list_cache_delete($tid); } } message(0, lang('delete_successfully')); } elseif ($action == 'post_like') { $header['title'] = lang('haya_post_like')." - " . $conf['sitename']; if (!$uid) { message(0, lang('haya_post_like_login_like_tip')); } if ($method == 'POST') { $pid = param('pid'); $post = post_read($pid); empty($post) AND message(0, lang('post_not_exists')); if ($post['isfirst'] == 1) { if (isset($haya_post_like_config['open_thread']) && $haya_post_like_config['open_thread'] != 1 ) { message(0, lang('haya_post_like_close_thread_tip')); } } else { if (isset($haya_post_like_config['open_post']) && $haya_post_like_config['open_post'] != 1 ) { message(0, lang('haya_post_like_close_post_tip')); } } haya_post_like_cache_delete($post['tid']); $haya_post_like_check = haya_post_like_find_by_uid_and_pid($uid, $pid); $action2 = param(2, 'create'); if ($action2 == 'create') { if (!empty($haya_post_like_check)) { message(0, lang('haya_post_like_user_has_like_tip')); } haya_post_like_create(array( 'tid' => $post['tid'], 'pid' => $pid, 'uid' => $user['uid'], 'create_date' => time(), 'create_ip' => $longip, )); if (isset($haya_post_like_config['post_like_count_type']) && $haya_post_like_config['post_like_count_type'] == 1 ) { $haya_post_like_count = haya_post_like_count(array('pid' => $pid)); post__update($post['pid'], array('likes' => $haya_post_like_count)); if ($post['isfirst'] == 1) { thread__update($post['tid'], array('likes' => $haya_post_like_count)); } } else { $haya_post_like_count = intval($post['likes']) + 1; haya_post_like_loves($pid, 1); if ($post['isfirst'] == 1) { thread__update($post['tid'], array('likes+' => 1)); } } $haya_post_like_msg = array( 'count' => intval($haya_post_like_count), 'msg' => lang('haya_post_like_like_success_tip'), ); if (function_exists("notice_send")) { $notice_user = ' '.$user['username'].''; $thread = thread_read($post['tid']); $thread['subject'] = notice_substr($thread['subject'], 20); $notice_thread = '《'.$thread['subject'].'》'; $post['message'] = htmlspecialchars(strip_tags($post['message'])); $post['message'] = notice_substr($post['message'], 40); $notice_post = '【'.$post['message'].'】'; if ($post['isfirst'] == 1) { $notice_msg_tpl = lang('haya_post_like_send_notice_for_thread'); } else { $notice_msg_tpl = lang('haya_post_like_send_notice_for_post'); } $notice_msg = str_replace( array('{thread}', '{post}', '{user}'), array($notice_thread, $notice_post, $notice_user), $notice_msg_tpl ); notice_send($user['uid'], $post['uid'], $notice_msg, 150); } message(1, $haya_post_like_msg); } elseif ($action2 == 'delete') { if (isset($haya_post_like_config['like_is_delete']) && $haya_post_like_config['like_is_delete'] != 1 ) { message(0, lang('haya_post_like_no_unlike_tip')); } if (empty($haya_post_like_check)) { message(0, lang('haya_post_like_user_no_like_tip')); } $post_like = haya_post_like_read_by_uid_and_pid($uid, $pid); $delete_time = intval($haya_post_like_config['delete_time']); if ($post_like['create_date'] + $delete_time > time()) { message(0, lang('haya_post_like_no_fast_like_tip')); } haya_post_like_delete_by_pid_and_uid($pid, $user['uid']); if (isset($haya_post_like_config['post_like_count_type']) && $haya_post_like_config['post_like_count_type'] == 1 ) { $haya_post_like_count = haya_post_like_count(array('pid' => $pid)); post__update($post['pid'], array('likes' => $haya_post_like_count)); if ($post['isfirst'] == 1) { thread__update($post['tid'], array('likes' => $haya_post_like_count)); } } else { $haya_post_like_count = MAX(0, intval($post['likes']) - 1); haya_post_like_loves($pid, -1); if ($post['isfirst'] == 1) { $haya_post_like_thread = thread__read($post['tid']); if ($haya_post_like_thread['likes'] > 0) { thread__update($post['tid'], array('likes-' => 1)); } } } $haya_post_like_msg = array( 'count' => intval($haya_post_like_count), 'msg' => lang('haya_post_like_unlike_success_tip'), ); message(1, $haya_post_like_msg); } message(0, lang('haya_post_like_like_error_tip')); } message(0, lang('haya_post_like_like_error_tip')); } elseif($action=='check' && $method=='POST'){ $opt = param('opt');//1:OK -1:NO -2:DELETE $data = param('data'); $act = param('act'); if(!$uid){message(-1,'拉取信息失败!');die();} if($group['see_check']!=1){message(-1,'无权操作!');die();} if($act=='0') check_set_thread_check($data,$opt); elseif($act=='1') check_set_post_check($data,$opt); elseif($act=='2') check_set_user_check($data,$opt); message(0,'审核完毕!'); } elseif($action=='recycle' &&$method=='POST') { $set_recycle = setting_get('tt_check'); if($set_recycle['recycle']!='1') {message(-1,'未开启回收站功能!');die();} if($group['see_check']!='1') {message(-1,'无权操作回收站功能!');die();} $opt=param('opt'); $data=param('data'); //-1:recovery 1:delete if($opt=='-1') recycle_thread_recovery($data); elseif($opt=='1') recycle_thread_delete_true($data); message(0,'操作完毕!'); } ?>